<?php
/**
 * 响应类
 */

class MgResponse
{
    protected  $response = array('status' => '0', 'msg' => 'request success', 'result' => []);

    public function __set($key, $value)
    {
        array_key_exists($key, $this->response) && $this->response[$key] = $value;

        $this->response['status'] = (string) $this->response['status'];

        return $this;
    }

    public function response()
    {
        exit(json_encode($this->response));
    }

    public function getResponse()
    {
        return $this->response;
    }
}
?>